package com.apping.template.config;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Properties;

public class ConfReader{
	//使用时需填上配置文件的路径
	private static ConfReader confReader = new ConfReader("");
	
	private ConfReader(String filePath){
		FileInputStream inputStream = null;
		this.properties = new Properties();
		try {
			inputStream = new FileInputStream(filePath);
			BufferedReader buffer = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));
			this.properties.load(buffer);
		}
		catch (Exception e){
			e.printStackTrace();
		}
	}
	
	public String getValue(String key){
		try{
			String value = this.properties.getProperty(key);
			return value;
		}
		catch(Exception ex){
			ex.printStackTrace();
		}
		return null;
	}
	
	public static synchronized ConfReader getInstance(){
		return confReader;
	}
	
	private Properties properties;
}
